/**
    @user: lcz
    @date: 2020/9/9
    @op:
**/
package controllers

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"im/app/services"
	"im/app/util/response"
)

type Upload struct {

}

// 上传文件
func (u *Upload) UploadFile(c *gin.Context) {
	file, _ := c.FormFile("file")
	uploadService := services.UploadService{}
	uploadService.Init()
	filepath,err := uploadService.Upload(file)
	if err != nil {
		response.ReturnJsonOk(c, err.Error())
		return
	}
	fullPath := fmt.Sprintf("%s/%s", "http://127.0.0.1:8088", filepath)

	response.ReturnJsonOk(c, "成功", fullPath)
}

